Skip to content

feat(runfiles): create pathlib api for runfiles library#3694

Merged
rickeylev merged 7 commits intobazel-contrib:mainfrom
rickeylev:runfiles.pathlib
Apr 14, 2026
Merged

feat(runfiles): create pathlib api for runfiles library#3694
rickeylev merged 7 commits intobazel-contrib:mainfrom
rickeylev:runfiles.pathlib

Conversation

@rickeylev
Copy link
Copy Markdown
Collaborator

This adds a pathlib.Path-based API for interacting with runfiles. This
makes it easier to interact with runfiles.

Fixes #3296

@rickeylev rickeylev requested a review from aignas as a code owner April 11, 2026 09:20
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Path class to the runfiles library, which implements the pathlib.PurePath API to allow for idiomatic path manipulation of Bazel runfiles. It also adds a root() method to the Runfiles class to return these new path objects. The review feedback suggests improving the robustness of the Path class by handling potential None values for the internal _runfiles attribute in str and runfiles_root methods, and using a more robust string formatting in repr.

Comment thread python/runfiles/runfiles.py Outdated
Comment thread python/runfiles/runfiles.py
Comment thread python/runfiles/runfiles.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Comment thread tests/runfiles/pathlib_test.py Outdated
Comment thread CHANGELOG.md
@rickeylev rickeylev enabled auto-merge April 13, 2026 04:50
@rickeylev rickeylev added this pull request to the merge queue Apr 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 13, 2026
@rickeylev rickeylev added this pull request to the merge queue Apr 14, 2026
Merged via the queue into bazel-contrib:main with commit 7369341 Apr 14, 2026
4 checks passed
@rickeylev rickeylev deleted the runfiles.pathlib branch April 14, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

runfiles: add pathlib.Path or importlib.Traversable API

2 participants